home *** CD-ROM | disk | FTP | other *** search
- /*
- File: AppleEvents.h
-
- Contains: AppleEvent Package Interfaces.
-
- Version: Technology: System 7.5
- Release: Universal Interfaces 3.0d3 on Copland DR1
-
- Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
- #ifndef __APPLEEVENTS__
- #define __APPLEEVENTS__
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- #if !FOR_PTR_BASED_AE
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
- #ifndef __MIXEDMODE__
- #include <MixedMode.h>
- #endif
- #ifndef __NOTIFICATION__
- #include <Notification.h>
- #endif
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
- #endif
- #endif
- #if FOR_SYSTEM8_PREEMPTIVE
- #ifndef __KERNEL__
- #include <Kernel.h>
- #endif
- #endif
- #ifndef __AEDATAMODEL__
- #include <AEDataModel.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
-
- enum {
- /* Keywords for Apple event parameters */
- keyDirectObject = '----',
- keyErrorNumber = 'errn',
- keyErrorString = 'errs',
- keyProcessSerialNumber = 'psn ', /* Keywords for special handlers */
- keyPreDispatch = 'phac', /* preHandler accessor call */
- keySelectProc = 'selh', /* more selector call */
- /* Keyword for recording */
- keyAERecorderCount = 'recr', /* available only in vers 1.0.1 and greater */
- /* Keyword for version information */
- keyAEVersion = 'vers' /* available only in vers 1.0.1 and greater */
- };
-
- /* Event Class */
-
- enum {
- kCoreEventClass = 'aevt'
- };
-
- /* Event ID’s */
-
- enum {
- kAEOpenApplication = 'oapp',
- kAEOpenDocuments = 'odoc',
- kAEPrintDocuments = 'pdoc',
- kAEQuitApplication = 'quit',
- kAEAnswer = 'ansr',
- kAEApplicationDied = 'obit'
- };
-
- /* Constants for recording */
-
- enum {
- kAEStartRecording = 'reca', /* available only in vers 1.0.1 and greater */
- kAEStopRecording = 'recc', /* available only in vers 1.0.1 and greater */
- kAENotifyStartRecording = 'rec1', /* available only in vers 1.0.1 and greater */
- kAENotifyStopRecording = 'rec0', /* available only in vers 1.0.1 and greater */
- kAENotifyRecording = 'recr' /* available only in vers 1.0.1 and greater */
- };
-
- #if FOR_SYSTEM8_PREEMPTIVE
- #if FOR_PTR_BASED_AE
- typedef struct OpaqueAEDispatcherID* AEDispatcherID;
- typedef struct OpaqueAEDispatcherRef* AEDispatcherRef;
- typedef struct OpaqueAEHandlerTableRef* AEHandlerTableRef;
- typedef struct OpaqueAEDelayedSendRef* AEDelayedSendRef;
- /* this will be removed by D11E3 or earlier (!!!)*/
- typedef AEHandlerTableRef AEHandlerTable;
- typedef OptionBits AEReceiveMode;
-
- enum {
- kAEReceiveForever = 0x00000000,
- kAEReceiveOneEvent = 0x00000001,
- kAEReceiveUntilUnhandledEvent = 0x00000002
- };
-
- #endif
- #endif
- /* parameter to AESend */
- typedef OptionBits AESendOptions;
-
- enum {
- kAENeverInteract = 0x00000010, /* server should not interact with user */
- kAECanInteract = 0x00000020, /* server may try to interact with user */
- kAEAlwaysInteract = 0x00000030, /* server should always interact with user where appropriate */
- kAECanSwitchLayer = 0x00000040, /* interaction may switch layer */
- kAEDontRecord = 0x00001000, /* don't record this event - available only in vers 1.0.1 and greater */
- kAEDontExecute = 0x00002000, /* don't send the event for recording - available only in vers 1.0.1 and greater */
- kAEProcessNonReplyEvents = 0x00008000 /* allow processing of non-reply events while awaiting synchronous AppleEvent reply */
- };
-
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- #if !FOR_PTR_BASED_AE
- typedef SInt32 AESendMode;
-
- enum {
- kAENoReply = 0x00000001, /* sender doesn't want a reply to event */
- kAEQueueReply = 0x00000002, /* sender wants a reply but won't wait */
- kAEWaitReply = 0x00000003, /* sender wants a reply and will wait */
- kAEDontReconnect = 0x00000080, /* don't reconnect if there is a sessClosedErr from PPCToolbox */
- kAEWantReceipt = 0x00000200 /* (nReturnReceipt) sender wants a receipt of message */
- };
-
- #endif
- #endif
- /* Constants for timeout durations */
-
- enum {
- kAEDefaultTimeout = -1, /* timeout value determined by AEM */
- kNoTimeOut = -2 /* wait until reply comes back, however long it takes */
- };
-
- /* priority param of AESend */
- typedef SInt16 AESendPriority;
-
- enum {
- kAENormalPriority = 0x00000000, /* post message at the end of the event queue */
- kAEHighPriority = 0x00000001 /* post message at the front of the event queue (same as nAttnMsg) */
- };
-
- typedef SInt8 AEEventSource;
-
- enum {
- kAEUnknownSource = 0,
- kAEDirectCall = 1,
- kAESameProcess = 2,
- kAELocalProcess = 3,
- kAERemoteProcess = 4
- };
-
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- #if !FOR_PTR_BASED_AE
- typedef pascal OSErr (*AEEventHandlerProcPtr)(const AppleEvent *theAppleEvent, AppleEvent *reply, UInt32 handlerRefcon);
- typedef pascal Boolean (*AEIdleProcPtr)(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn);
- typedef pascal Boolean (*AEFilterProcPtr)(EventRecord *theEvent, long returnID, long transactionID, const AEAddressDesc *sender);
-
- #if GENERATINGCFM
- typedef UniversalProcPtr AEEventHandlerUPP;
- typedef UniversalProcPtr AEIdleUPP;
- typedef UniversalProcPtr AEFilterUPP;
- #else
- typedef AEEventHandlerProcPtr AEEventHandlerUPP;
- typedef AEIdleProcPtr AEIdleUPP;
- typedef AEFilterProcPtr AEFilterUPP;
- #endif
-
- enum {
- uppAEEventHandlerProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(const AppleEvent *)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AppleEvent *)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(UInt32))),
- uppAEIdleProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(EventRecord *)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long *)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(RgnHandle *))),
- uppAEFilterProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(EventRecord *)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
- | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(const AEAddressDesc *)))
- };
-
- #if GENERATINGCFM
- #define NewAEEventHandlerProc(userRoutine) \
- (AEEventHandlerUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEEventHandlerProcInfo, GetCurrentArchitecture())
- #define NewAEIdleProc(userRoutine) \
- (AEIdleUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEIdleProcInfo, GetCurrentArchitecture())
- #define NewAEFilterProc(userRoutine) \
- (AEFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEFilterProcInfo, GetCurrentArchitecture())
- #else
- #define NewAEEventHandlerProc(userRoutine) \
- ((AEEventHandlerUPP) (userRoutine))
- #define NewAEIdleProc(userRoutine) \
- ((AEIdleUPP) (userRoutine))
- #define NewAEFilterProc(userRoutine) \
- ((AEFilterUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define CallAEEventHandlerProc(userRoutine, theAppleEvent, reply, handlerRefcon) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppAEEventHandlerProcInfo, (theAppleEvent), (reply), (handlerRefcon))
- #define CallAEIdleProc(userRoutine, theEvent, sleepTime, mouseRgn) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppAEIdleProcInfo, (theEvent), (sleepTime), (mouseRgn))
- #define CallAEFilterProc(userRoutine, theEvent, returnID, transactionID, sender) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppAEFilterProcInfo, (theEvent), (returnID), (transactionID), (sender))
- #else
- #define CallAEEventHandlerProc(userRoutine, theAppleEvent, reply, handlerRefcon) \
- (*(userRoutine))((theAppleEvent), (reply), (handlerRefcon))
- #define CallAEIdleProc(userRoutine, theEvent, sleepTime, mouseRgn) \
- (*(userRoutine))((theEvent), (sleepTime), (mouseRgn))
- #define CallAEFilterProc(userRoutine, theEvent, returnID, transactionID, sender) \
- (*(userRoutine))((theEvent), (returnID), (transactionID), (sender))
- #endif
- #endif
- #endif
- #if FOR_SYSTEM8_PREEMPTIVE
- #if FOR_PTR_BASED_AE
- typedef OSStatus (*AEEventHandlerProc)(const AppleEvent *theAppleEvent, AppleEvent *reply, void *handlerRefcon, AEHandlerTableRef handlerTable);
- #endif
- #endif
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- #if !FOR_PTR_BASED_AE
- /*
- *************************************************************************
- The next couple of calls are basic routines used to create, send,
- and process AppleEvents.
- *************************************************************************
- */
- extern pascal OSErr AESend(const AppleEvent *theAppleEvent, AppleEvent *reply, AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks, AEIdleUPP idleProc, AEFilterUPP filterProc)
- THREEWORDINLINE(0x303C, 0x0D17, 0xA816);
-
- extern pascal OSErr AEProcessAppleEvent(const EventRecord *theEventRecord)
- THREEWORDINLINE(0x303C, 0x021B, 0xA816);
-
- #endif
- #endif
- #if FOR_SYSTEM8_PREEMPTIVE
- #if FOR_PTR_BASED_AE
- /*
- *************************************************************************
- The next set of calls are basic routines used to send and process AppleEvents.
- *************************************************************************
- */
- /*
- the reply param MUST be created by the caller if a reply is requested
- otherwise, the caller must specify nil, or a NULL AppleEvent, if no reply is requested
- */
- extern OSStatus AESendEvent(const AppleEvent *theAppleEvent, AppleEvent *reply, AESendOptions sendOpts, AESendPriority sendPriority, Duration timeoutDuration);
-
- extern OSStatus AESendEventQueueReply(const AppleEvent *theAppleEvent, const AEAddressDesc *replyAddress, AESendOptions sendOpts, AESendPriority sendPriority);
-
- /*
- the reply param MUST be created by the caller if a reply is requested
- otherwise, the caller must specify nil, or a NULL AppleEvent, if no reply is requested
- */
- extern OSStatus AESendEventToSelf(const AppleEvent *theAppleEvent, AppleEvent *reply, AEDispatcherRef whichDispatcher, AESendOptions sendOpts);
-
- extern OSStatus AESendDelayed(const AppleEvent *theAppleEvent, Duration delayForSend, AEDelayedSendRef *delayedSend);
-
- extern OSStatus AECancelDelayedSend(AEDelayedSendRef delayedSend);
-
- /*
- *************************************************************************
- The next couple of calls are for causing kernel asynchronous completion
- notifications to send an AppleEvent when they fire.
- *************************************************************************
- */
- extern OSStatus AECreateNotifier(const AppleEvent *theAppleEvent, KernelNotification *theNotification);
-
- extern OSStatus AEDisposeNotifier(const KernelNotification *theNotification);
-
- #endif
- #endif
- /*
- Note: during event processing, an event handler may realize that it is likely
- to exceed the client's timeout limit. Passing the reply to this
- routine causes a wait event to be generated that asks the client
- for more time.
- */
- #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
- extern pascal OSErr AEResetTimer(const AppleEvent *reply)
- THREEWORDINLINE(0x303C, 0x0219, 0xA816);
-
- #endif
- /*
- *************************************************************************
- The following three calls are used to allow applications to behave
- courteously when a user interaction such as a dialog box is needed.
- *************************************************************************
- */
- #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
- typedef SInt8 AEInteractAllowed;
-
- enum {
- kAEInteractWithSelf = 0,
- kAEInteractWithLocal = 1,
- kAEInteractWithAll = 2
- };
-
- extern pascal OSErr AEGetInteractionAllowed(AEInteractAllowed *level)
- THREEWORDINLINE(0x303C, 0x021D, 0xA816);
-
- extern pascal OSErr AESetInteractionAllowed(AEInteractAllowed level)
- THREEWORDINLINE(0x303C, 0x011E, 0xA816);
-
- #endif
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- #if !FOR_PTR_BASED_AE
- extern pascal OSErr AEInteractWithUser(long timeOutInTicks, NMRecPtr nmReqPtr, AEIdleUPP idleProc)
- THREEWORDINLINE(0x303C, 0x061C, 0xA816);
-
- #endif
- #endif
- #if FOR_SYSTEM8_PREEMPTIVE
- #if FOR_PTR_BASED_AE
- /*
- *************************************************************************
- These calls are used to create and dispose Apple event handler tables,
- as well as to install, get and remove handlers from them.
- *************************************************************************
- */
- extern OSStatus AENewHandlerTable(AEHandlerTableRef *newTable, void *refCon);
-
- extern OSStatus AENewFilterHandlerTable(AEHandlerTableRef *newTable, void *refCon);
-
- extern OSStatus AEShareHandlerTable(AEHandlerTableRef table, void *newRefcon, AEHandlerTableRef *newSharedReference);
-
- extern OSStatus AEDisposeHandlerTable(AEHandlerTableRef table);
-
- extern OSStatus AEGetHandlerTableRefCon(AEHandlerTableRef table, void **refCon);
-
- extern OSStatus AEInstallHandler(AEHandlerTableRef table, AEEventClass handlerClass, AEEventID handlerID, AEEventHandlerProc handler, void *handlerRefcon);
-
- extern OSStatus AERemoveHandler(AEHandlerTableRef table, AEEventClass handlerClass, AEEventID handlerID, AEEventHandlerProc handler);
-
- extern OSStatus AEGetHandler(AEHandlerTableRef table, AEEventClass handlerClass, AEEventID handlerID, AEEventHandlerProc *handler, void **handlerRefcon);
-
- /*
- *************************************************************************
- These calls are used to setup and get events from Apple event dispatchers.
- *************************************************************************
- */
- extern AEDispatcherRef AEGetDefaultDispatcher(void );
-
- extern OSStatus AECreateEventDispatcher(AEDispatcherRef *newDispatcher, MemAllocatorRef allocator);
-
- extern OSStatus AEDisposeEventDispatcher(AEDispatcherRef deadDispatcher);
-
- extern OSStatus AEGetEventDispatcherID(AEDispatcherRef dispatcher, AEDispatcherID *globalIdentity);
-
- extern OSStatus AEPushDispatcherHandlerTable(AEDispatcherRef dispatcher, AEHandlerTableRef table);
-
- extern OSStatus AEPopDispatcherHandlerTable(AEDispatcherRef dispatcher, AEHandlerTableRef *table);
-
- extern OSStatus AEGetDispatcherTopHandlerTable(AEDispatcherRef dispatcher, AEHandlerTableRef *table);
-
- extern OSStatus AEReceive(AEDispatcherRef waitDispatcher, AEReceiveMode receiveMode);
-
- #endif
- #endif
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- #if !FOR_PTR_BASED_AE
- /*
- *************************************************************************
- These calls are used to set up and modify the event dispatch table.
- *************************************************************************
- */
- extern pascal OSErr AEInstallEventHandler(AEEventClass theAEEventClass, AEEventID theAEEventID, AEEventHandlerUPP handler, long handlerRefcon, Boolean isSysHandler)
- THREEWORDINLINE(0x303C, 0x091F, 0xA816);
-
- extern pascal OSErr AERemoveEventHandler(AEEventClass theAEEventClass, AEEventID theAEEventID, AEEventHandlerUPP handler, Boolean isSysHandler)
- THREEWORDINLINE(0x303C, 0x0720, 0xA816);
-
- extern pascal OSErr AEGetEventHandler(AEEventClass theAEEventClass, AEEventID theAEEventID, AEEventHandlerUPP *handler, long *handlerRefcon, Boolean isSysHandler)
- THREEWORDINLINE(0x303C, 0x0921, 0xA816);
-
- /*
- *************************************************************************
- The following four calls are available for applications which need more
- sophisticated control over when and how events are processed. Applications
- which implement multi-session servers or which implement their own
- internal event queueing will probably be the major clients of these
- routines. They can be called from within a handler to prevent the AEM from
- disposing of the AppleEvent when the handler returns. They can be used to
- asynchronously process the event (as MacApp does).
- *************************************************************************
- */
- extern pascal OSErr AESuspendTheCurrentEvent(const AppleEvent *theAppleEvent)
- THREEWORDINLINE(0x303C, 0x022B, 0xA816);
-
- /*
- Note: The following routine tells the AppleEvent manager that processing
- is either about to resume or has been completed on a previously suspended
- event. The procPtr passed in as the dispatcher parameter will be called to
- attempt to redispatch the event. Several constants for the dispatcher
- parameter allow special behavior. They are:
- - kAEUseStandardDispatch means redispatch as if the event was just
- received, using the standard AppleEvent dispatch mechanism.
- - kAENoDispatch means ignore the parameter.
- Use this in the case where the event has been handled and no
- redispatch is needed.
- - non nil means call the routine which the dispatcher points to.
- */
- /* Constants for Refcon in AEResumeTheCurrentEvent with kAEUseStandardDispatch */
-
- enum {
- kAEDoNotIgnoreHandler = 0x00000000,
- kAEIgnoreAppPhacHandler = 0x00000001, /* available only in vers 1.0.1 and greater */
- kAEIgnoreAppEventHandler = 0x00000002, /* available only in vers 1.0.1 and greater */
- kAEIgnoreSysPhacHandler = 0x00000004, /* available only in vers 1.0.1 and greater */
- kAEIgnoreSysEventHandler = 0x00000008, /* available only in vers 1.0.1 and greater */
- kAEIngoreBuiltInEventHandler = 0x00000010, /* available only in vers 1.0.1 and greater */
- kAEDontDisposeOnResume = 0x80000000 /* available only in vers 1.0.1 and greater */
- };
-
- /* Constants for AEResumeTheCurrentEvent */
-
- enum {
- kAENoDispatch = 0, /* dispatch parameter to AEResumeTheCurrentEvent takes a pointer to a dispatch */
- kAEUseStandardDispatch = 0xFFFFFFFF /* table, or one of these two constants */
- };
-
- extern pascal OSErr AEResumeTheCurrentEvent(const AppleEvent *theAppleEvent, const AppleEvent *reply, AEEventHandlerUPP dispatcher, long handlerRefcon)
- THREEWORDINLINE(0x303C, 0x0818, 0xA816);
-
- extern pascal OSErr AEGetTheCurrentEvent(AppleEvent *theAppleEvent)
- THREEWORDINLINE(0x303C, 0x021A, 0xA816);
-
- extern pascal OSErr AESetTheCurrentEvent(const AppleEvent *theAppleEvent)
- THREEWORDINLINE(0x303C, 0x022C, 0xA816);
-
- #endif
- #endif
- /*
- *************************************************************************
- These calls are used to set up and modify special hooks into the
- AppleEvent manager.
- *************************************************************************
- */
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- #if !FOR_PTR_BASED_AE
- extern pascal OSErr AEInstallSpecialHandler(AEKeyword functionClass, UniversalProcPtr handler, Boolean isSysHandler)
- THREEWORDINLINE(0x303C, 0x0500, 0xA816);
-
- extern pascal OSErr AERemoveSpecialHandler(AEKeyword functionClass, UniversalProcPtr handler, Boolean isSysHandler)
- THREEWORDINLINE(0x303C, 0x0501, 0xA816);
-
- extern pascal OSErr AEGetSpecialHandler(AEKeyword functionClass, UniversalProcPtr *handler, Boolean isSysHandler)
- THREEWORDINLINE(0x303C, 0x052D, 0xA816);
-
- #endif
- #endif
- #if FOR_SYSTEM8_PREEMPTIVE
- #if FOR_PTR_BASED_AE
- extern OSStatus AEInstallSpecialCallback(AEDispatcherRef dispatcher, AEKeyword functionClass, ProcPtr handler);
-
- extern OSStatus AERemoveSpecialCallback(AEDispatcherRef dispatcher, AEKeyword functionClass, ProcPtr handler);
-
- extern OSStatus AEGetSpecialCallback(AEDispatcherRef dispatcher, AEKeyword functionClass, ProcPtr *handler);
-
- #endif
- #endif
- /*
- *************************************************************************
- This call was added in version 1.0.1. If called with the keyword
- keyAERecorderCount ('recr'), the number of recorders that are
- currently active is returned in 'result'
- (available only in vers 1.0.1 and greater).
- *************************************************************************
- */
- #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
- extern pascal OSErr AEManagerInfo(AEKeyword keyWord, long *result)
- THREEWORDINLINE(0x303C, 0x0441, 0xA816);
-
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __APPLEEVENTS__ */
-
-